package com.parking.order.controller;

import cn.hutool.core.bean.BeanUtil;
import com.parking.common.core.model.PageInfo;
import com.parking.common.core.model.Result;
import com.parking.common.core.util.JwtUtil;
import com.parking.order.model.param.MoneyCertifiedParam;
import com.parking.order.model.form.MoneyCertifiedForm;
import com.parking.order.service.ICentifiedMoneyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  物业流水控制层
 * </p>
 *
 * @author 吴彦祖
 * @since 2023年11月28日
 */
@RestController
@Api(tags = "物业流水")
@RequestMapping("/centifiedMoney")
public class CentifiedMoneyController {
    /**
     * 物业流水服务层
     * */
    @Autowired
    private ICentifiedMoneyService centifiedMoneyService;
    /**
     * 物业查询流水
     * 参数: 物业token authorization
     *      开始日期 startDate
     *      结束日期 endDate
     *      订单编号 orderInfoNum
     *      流水类型 moneyType 0普通 1取消 2超时
     *      页数 pageNum
     *      每页大小 pegeSize
     * 结果: 订单编号 orderInfoNum
     *      流水类型 moneyType 普通/取消/超时
     *      支付时间 addTime
     *      流水金额 moneyNum
     * */
    @GetMapping("/findMoney.certified")
    @ApiOperation("物业查询流水")
    public Result<PageInfo> findMoneyCertified(MoneyCertifiedForm form, @RequestHeader String authorization) throws Exception {
        MoneyCertifiedParam param = BeanUtil.toBean(form,MoneyCertifiedParam.class);
        param.setCertifiedId(JwtUtil.getCertifiedAccountId(authorization));
        PageInfo page = centifiedMoneyService.findMoneyCertified(param);
        return Result.getResult(PageInfo.class).setMessage("物业查询流水成功").setData(page);
    }

}

